﻿using System;
using LogikBug.Async.Tasks.Entities;

namespace LogikBug.Async.Tasks
{
	public class FuncAgent<TResult> : Agent<FuncModel<TResult>>
	{
		public FuncAgent(Func<TResult> func) : this(FuncModel.Create(func))
		{
		}

		public FuncAgent(FuncModel<TResult> model) : base(model)
		{
		}

		public override void Execute()
		{
			Result.Value = Model.Invoke();
		}
	}

	public class FuncAgent<T, TResult> : Agent<FuncModel<T, TResult>>
	{
		public FuncAgent(T item, Func<T, TResult> func) : this(FuncModel.Create(item, func))
		{
		}

		public FuncAgent(FuncModel<T, TResult> model) : base(model)
		{
		}

		public override void Execute()
		{
			Result.Value = Model.Invoke();
		}
	}

	public class FuncAgent<T1, T2, TResult> : Agent<FuncModel<T1, T2, TResult>>
	{
		public FuncAgent(T1 item1, T2 item2, Func<T1, T2, TResult> func) : this(FuncModel.Create(item1, item2, func))
		{
		}

		public FuncAgent(FuncModel<T1, T2, TResult> model) : base(model)
		{
		}

		public override void Execute()
		{
			Result.Value = Model.Invoke();
		}
	}
}
